﻿@using com.hyrentals.webcommon.extensions
@using com.hyrentals.webportal.Config
@using com.hyrentals.data
@using com.hyrentals.common

@model com.hyrentals.data.RV
@{
    Html.AddStyle("css/rv");
    Html.AddTailScript("js/rv-pricing");
    RVPricing pricing = Model.Pricing;
    string rentalRateDailyValue = (pricing == null || pricing.RentalRateDaily == null) ? null : pricing.RentalRateDaily.ToString();
    string rentalRateWeeklyValue = (pricing == null || pricing.RentalRateWeekly == null) ? null : pricing.RentalRateWeekly.ToString();
    string rentalRateMonthlyValue = (pricing == null || pricing.RentalRateMonthly == null) ? null : pricing.RentalRateMonthly.ToString();
    string milageFreeMilesDailyValue = (pricing == null || pricing.MilageFreeMilesDaily == null) ? null : pricing.MilageFreeMilesDaily.ToString();
    string milageFreeMilesWeeklyValue = (pricing == null || pricing.MilageFreeMilesWeekly == null) ? null : pricing.MilageFreeMilesWeekly.ToString();
    string milageFreeMilesMonthlyValue = (pricing == null || pricing.MilageFreeMilesMonthly == null) ? null : pricing.MilageFreeMilesMonthly.ToString();
    string milagePerExtraMileDailyValue = (pricing == null || pricing.MilagePerExtraMileDaily == null) ? null : pricing.MilagePerExtraMileDaily.ToString();
    string milagePerExtraMileWeeklyValue = (pricing == null || pricing.MilagePerExtraMileWeekly == null) ? null : pricing.MilagePerExtraMileWeekly.ToString();
    string milagePerExtraMileMonthlyValue = (pricing == null || pricing.MilagePerExtraMileMonthly == null) ? null : pricing.MilagePerExtraMileMonthly.ToString();
    string depositNonrefundableSecurityDownPaymentValue = (pricing == null || pricing.DepositNonrefundableSecurityDownPayment == null) ? null : pricing.DepositNonrefundableSecurityDownPayment.ToString();
    string depositRefundableDamageProtectionValue = (pricing == null || pricing.DepositRefundableDamageProtection == null) ? null : pricing.DepositRefundableDamageProtection.ToString();
    string depositRefundableCleaningChargeValue = (pricing == null || pricing.DepositRefundableCleaningCharge == null) ? null : pricing.DepositRefundableCleaningCharge.ToString();
    string lateChargePerHourValue = (pricing == null || pricing.LateChargePerHour == null) ? null : pricing.LateChargePerHour.ToString();

    string calendarUrl = string.Format("/rv/{0}/edit/calendar", Model.Id);
    string pricingUrl = string.Format("/rv/{0}/edit/pricing", Model.Id);
    string overviewUrl = string.Format("/rv/{0}/edit/overview", Model.Id);
    string automotiveUrl = string.Format("/rv/{0}/edit/automotive", Model.Id);
    string interiorUrl = string.Format("/rv/{0}/edit/interior", Model.Id);
    string photosUrl = string.Format("/rv/{0}/edit/photos", Model.Id);
    string addressUrl = string.Format("/rv/{0}/edit/address", Model.Id);
   
}

<div class="layout-primary">
    <div class="layout-primary-left">
        <ul class="manage-rv-nav">
            <li><a href="@calendarUrl">Calendar</a></li>
            <li><a class="active" href="@pricingUrl">Pricing</a></li>
            <li><a href="@overviewUrl">Overview</a></li>
            <li><a href="@automotiveUrl">RV Details</a></li>
            <li><a href="@photosUrl">Photos</a></li>
            <li><a href="@addressUrl">Address</a></li>
        </ul>
    </div>
    <div class="layout-primary-middle">
        <form id="J_Pricing" class="form-s3" action="" method="post">
            <div class="valid-simple">
                <input type="hidden" value="@Model.Id" name="id"/>
                <div class="section">
                    <h2>Rental Rate</h2>
                    <div class="row">
                        <span class="money">$</span>
                        <input id="rental_rate_daily" class="input-text" type="text" name="rentalRateDaily"  value="@rentalRateDailyValue" data-msgbox="#msg_rental_rate_daily" />
                        <span class="unit">Per Day</span>
                        <span id="msg_rental_rate_daily" style="display: none;"></span>
                    </div>
                    <a class="btn more-btn" href="javascript:;" data-more-id="J_MoreRentalRate">More price option</a>
                    <div id="J_MoreRentalRate" class="more" style="display: none;">
                        <div class="row">
                            <span class="money">$</span>
                            <input id="rental_rate_weekly" class="input-text" type="text" name="rentalRateWeekly"  value="@rentalRateWeeklyValue" data-msgbox="#msg_rental_rate_weekly" />
                            <span class="unit">Per Week</span>
                            <span id="msg_rental_rate_weekly" style="display: none;"></span>
                        </div>
                        <div class="row">
                            <span class="money">$</span>
                            <input id="rental_rate_monthly" class="input-text" type="text" name="rentalRateMonthly"  value="@rentalRateMonthlyValue" data-msgbox="#msg_rental_rate_monthly" />
                            <span class="unit">Per Month</span>
                            <span id="msg_rental_rate_monthly" style="display: none;"></span>
                        </div>
                    </div>
                </div>
                <div class="section">
                    <h2>Milage</h2>
                    <div class="row">
                        <span>Free</span>
                        <input id="milage_free_miles_daily" class="input-text" type="text" name="milageFreeMilesDaily"  value="@milageFreeMilesDailyValue" data-msgbox="#msg_milage_free_miles_daily" />
                        <span class="unit">Per Day</span>
                        <span id="msg_milage_free_miles_daily" style="display: none;"></span>
                        <span class="money">$</span>
                        <input id="milage_per_extra_mile_daily" class="input-text" type="text" name="milagePerExtraMileDaily" value="@milagePerExtraMileDailyValue" data-msgbox="#msg_milage_per_extra_mile_daily" />
                        <span class="unit">Per extra mile</span>
                        <span id="msg_milage_per_extra_mile_daily" style="display: none;"></span>
                    </div>
                    <a class="btn more-btn" href="javascript:;" data-more-id="J_MoreMilage">More mileage option</a>
                    <div id="J_MoreMilage" class="more" style="display: none;">
                        <div class="row">
                            <span>Free</span>
                            <input id="milage_free_miles_weekly" class="input-text" type="text" name="milageFreeMilesWeekly" value="@milageFreeMilesWeeklyValue" data-msgbox="#msg_milage_free_miles_weekly" />
                            <span class="unit">Per Weekly</span>
                            <span id="msg_milage_free_miles_weekly" style="display: none;"></span>
                            <span class="money">$</span>
                            <input id="milage_per_extra_mile_weekly" class="input-text" type="text" name="milagePerExtraMileWeekly" value="@milagePerExtraMileWeeklyValue" data-msgbox="#msg_milage_per_extra_mile_weekly" />
                            <span class="unit">Per extra mile</span>
                            <span id="msg_milage_per_extra_mile_weekly" style="display: none;"></span>
                        </div>
                        <div class="row">
                            <span>Free</span>
                            <input id="milage_free_miles_monthly" class="input-text" type="text" name="milageFreeMilesMonthly" value="@milageFreeMilesMonthlyValue" data-msgbox="#msg_milage_free_miles_monthly" />
                            <span class="unit">Per Monthly</span>
                            <span id="msg_milage_free_miles_monthly" style="display: none;"></span>
                            <span class="money">$</span>
                            <input id="milage_per_extra_mile_monthly" class="input-text" type="text" name="milagePerExtraMileMonthly" value="@milagePerExtraMileMonthlyValue" data-msgbox="#msg_milage_per_extra_mile_monthly" />
                            <span class="unit">Per extra mile</span>
                            <span id="msg_milage_per_extra_mile_monthly" style="display: none;"></span>
                        </div>
                    </div>
                </div>
                <div class="section">
                    <h2>Deposit</h2>
                    <div class="row">
                        <span class="money">$</span>
                        <input id="deposit_nonrefundable_security_down_payment" class="input-text" type="text" value="@depositNonrefundableSecurityDownPaymentValue" name="depositNonrefundableSecurityDownPayment"  data-msgbox="#msg_deposit_nonrefundable_security_down_payment" />
                        <span class="unit">for Non-refundable Security Down Payment</span>
                        <span id="msg_deposit_nonrefundable_security_down_payment" style="display: none;"></span>
                    </div>
                    <a class="btn more-btn" href="javascript:;" data-more-id="J_MoreDeposit">More deposit</a>
                    <div id="J_MoreDeposit" class="more" style="display: none;">
                        <div class="row">
                            <span class="money">$</span>
                            <input id="deposit_refundable_damage_protection" class="input-text" type="text" name="depositRefundableDamageProtection" value="@depositRefundableDamageProtectionValue" data-msgbox="#msg_deposit_refundable_damage_protection" />
                            <span class="unit">for Refundable Damage Protection</span>
                            <span id="msg_deposit_refundable_damage_protection" style="display: none;"></span>
                        </div>
                        <div class="row">
                            <span class="money">$</span>
                            <input id="deposit_refundable_cleaning_charge" class="input-text" type="text" name="depositRefundableCleaningCharge" value="@depositRefundableCleaningChargeValue" data-msgbox="#msg_deposit_refundable_cleaning_charge" />
                            <span class="unit">for Refundable Cleaning Charge</span>
                            <span id="msg_deposit_refundable_cleaning_charge" style="display: none;"></span>
                        </div>
                    </div>
                </div>
                <div class="section">
                    <h2>Late charge</h2>
                    <div class="row">
                        <span class="money">$</span>
                        <input id="late_charge_per_hour" class="input-text" type="text" name="lateChargePerHour" value="@lateChargePerHourValue" data-msgbox="#msg_late_charge_per_hour" />
                        <span class="unit">Per hour for extented days or late return</span>
                        <span id="msg_late_charge_per_hour" style="display: none;"></span>
                    </div>
                </div>
                <div class="section">
                    <h2>Other itemized charges</h2>
                    <ul class="itemized-charge-list">
                    @if (pricing != null && pricing.OtherCharges != null)
                    {
                        foreach (RVItermizedCharge itermizedCharge in pricing.OtherCharges)
                        {
                            string index = GUIDHelper.Generate32GUID();
                            string labelId = "ic_name_" + index;
                            string labelName = string.Format("itemizedCharges[{0}].Name", index);
                            string labelMsgId = "msg_ic_name_" + index;
                            string labelMsgId2 = "#" + labelMsgId;

                            string chargeId = "ic_charge_" + index;
                            string chargeName = string.Format("itemizedCharges[{0}].Charge", index);
                            string chargeMsgId = "msg_ic_charge_" + index;
                            string chargeMsgId2 = "#" + chargeMsgId;

                            string frequenceId = "ic_freq_" + index;
                            string frequenceName = string.Format("itemizedCharges[{0}].Frequence", index);
                            
                            <li class="row clearfix">
                                <input type="hidden" name="itemizedCharges.Index" value="@index"/>
                                <div class="input">
                                    <input id="@labelId" class="input-text name" type="text" name="@labelName" value="@itermizedCharge.Name" data-msgbox="@labelMsgId2" />
                                    <p id="@labelMsgId" style="display: none;"></p>
                                </div>
                                <span class="unit">for</span>
                                <span class="money">$</span>
                                <div class="input">
                                    <input id="@chargeId" class="input-text charge" type="text" name="@chargeName" value="@itermizedCharge.Charge" data-msgbox="@chargeMsgId2" />
                                    <p id="@chargeMsgId" style="display: none;"></p>
                                </div>
                                <select id="@frequenceId" class="select" name="@frequenceName">
                                @{
                                    foreach (FrequenceEnum frequence in Enum.GetValues(typeof(FrequenceEnum)))
                                    {
                                        byte freqIndex = (byte)frequence;
                                        string name = NameMapping.FrequenceEnumNameArray[freqIndex];
                                        if (frequence == itermizedCharge.Frequence)
                                        {
                                            <option value="@freqIndex" selected="selected">@name</option>
                                        }
                                        else
                                        {
                                            <option value="@freqIndex">@name</option>
                                        }
                                    }
                                }
                                </select>
                                <a class="delete" href="javascript:;" onclick="@string.Format("func.deleteItemizedCharge('{0}', '{1}', this); return false;", labelId, chargeId)">Delete</a>
                            </li>
                        }
                    }
                    </ul>
                    <a id="J_AddItemizedCharge" class="btn" href="javascript:;">Add an item</a>
                </div>
                <div class="section"><a id="J_Sumbit" href="javascript:;" class="btn btn-large">Save</a></div>
            </div>
        </form>
    </div>
    <div class="layout-primary-right"></div>
</div>